package com.doom.a3rdlibdemo;

public abstract class Observable<T> implements ObservableSource{
    @Override
    public void subscribe(Observer observer) {
        subscribeActual(observer);
    }

    protected abstract void subscribeActual(Observer<T> observer);

    public static<T> Observable<T> create(ObservableOnSubscribe<T> source) {
        return new ObservableCreate(source);
    }

    public<R> ObservableMap<T, R> map(Function<T, R> function) {
        return new ObservableMap<T, R>(this, function);
    }

    public final Observable<T> subscribeOn() {
        return new ObservableSubscribeOn<>(this);
    }

    public final Observable<T> observeOn() {
        return new ObservableObserveOn<>(this);
    }

}
